<template>
  <div class="card">
    <van-popup v-model="show" position="bottom">
      <van-nav-bar title="答题卡题">
        <template #right>
          <span
            ><span style="color:red">{{ finishQue }}</span
            >/{{ questionList.length }}题</span
          >
        </template>
      </van-nav-bar>
      <div class="title-box">共{{ questionList.length }}题</div>
      <div class="content">
        <ul>
          <li
            class="item"
            :class="{
              current: index === currentQuestion,
              right: item.isRight === true,
              error: item.isRight === false
            }"
            v-for="(item, index) in questionList"
            :key="index"
            @click="checkQuestion(item, index)"
          >
            {{ index + 1 }}
          </li>
        </ul>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  props: ['questionList', 'currentQuestion'],
  data () {
    return {
      show: false,
      ans: 0
    }
  },
  methods: {
    checkQuestion (item, index) {
      this.$emit('update:currentQuestion', index)
      this.$emit('getQueItem', item)
    }
  },
  computed: {
    finishQue () {
      return this.questionList.filter(item => 'subimt' in item).length
    }
  }
}
</script>

<style lang="less" scoped>
.card {
  .title-box {
    font-size: 14px;
    color: #b4b4bd;
    background-color: #f7f4f5;
    height: 44px;
    line-height: 44px;
    padding-left: 15px;
  }
  .content {
    padding: 20px 15px 10px;
    ul {
      display: flex;
      flex-wrap: wrap;
      justify-content: flex-start;
      .item {
        width: 33px;
        height: 33px;
        margin-bottom: 19px;
        margin-left: 24px;
        border-radius: 50%;
        text-align: center;
        line-height: 33px;
        border: 1px solid #b4b4bd;
        font-size: 14px;
        color: #b4b4bd;
        &:nth-of-type(6n-5) {
          margin-left: 12px;
        }
        &:nth-of-type(6n) {
          margin-right: 12px;
        }
        &.current {
          color: #181a39;
          border-color: #181a39;
        }
        &.error,
        &.error.current {
          border-color: transparent;
          background: #ffefea;
          color: #ff4949;
        }
        &.right,
        &.right.current {
          border-color: transparent;
          background-color: #ddfad9;
          color: #1dc779;
        }
      }
    }
  }
}
</style>
